package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzKsjieguo;
import com.ruoyi.system.service.IDzKsjieguoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考试结果Controller
 * 
 * @author ruoyi
 * @date 2022-09-02
 */
@RestController
@RequestMapping("/system/ksjieguo")
public class DzKsjieguoController extends BaseController
{
    @Autowired
    private IDzKsjieguoService dzKsjieguoService;

    /**
     * 查询考试结果列表
     */
    @PreAuthorize("@ss.hasPermi('system:ksjieguo:list')")
    @GetMapping("/list")
    public TableDataInfo list(DzKsjieguo dzKsjieguo)
    {
        startPage();
        List<DzKsjieguo> list = dzKsjieguoService.selectDzKsjieguoList(dzKsjieguo);
        return getDataTable(list);
    }

    /**
     * 导出考试结果列表
     */
    @PreAuthorize("@ss.hasPermi('system:ksjieguo:export')")
    @Log(title = "考试结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzKsjieguo dzKsjieguo)
    {
        List<DzKsjieguo> list = dzKsjieguoService.selectDzKsjieguoList(dzKsjieguo);
        ExcelUtil<DzKsjieguo> util = new ExcelUtil<DzKsjieguo>(DzKsjieguo.class);
        util.exportExcel(response, list, "考试结果数据");
    }

    /**
     * 获取考试结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ksjieguo:query')")
    @GetMapping(value = "/{jgId}")
    public AjaxResult getInfo(@PathVariable("jgId") Long jgId)
    {
        return AjaxResult.success(dzKsjieguoService.selectDzKsjieguoByJgId(jgId));
    }

    /**
     * 新增考试结果
     */
    @PreAuthorize("@ss.hasPermi('system:ksjieguo:add')")
    @Log(title = "考试结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzKsjieguo dzKsjieguo)
    {
        return toAjax(dzKsjieguoService.insertDzKsjieguo(dzKsjieguo));
    }

    /**
     * 修改考试结果
     */
    @PreAuthorize("@ss.hasPermi('system:ksjieguo:edit')")
    @Log(title = "考试结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzKsjieguo dzKsjieguo)
    {
        return toAjax(dzKsjieguoService.updateDzKsjieguo(dzKsjieguo));
    }

    /**
     * 删除考试结果
     */
    @PreAuthorize("@ss.hasPermi('system:ksjieguo:remove')")
    @Log(title = "考试结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jgIds}")
    public AjaxResult remove(@PathVariable Long[] jgIds)
    {
        return toAjax(dzKsjieguoService.deleteDzKsjieguoByJgIds(jgIds));
    }
}
